<?php
	header("Content-type: text/html; charset=utf-8");
	function TextC($text,$n1,$n2) {
        $n = rand($n1,$n2);
        $t="";
        $i=0;
		$k=count($text)-1;
        while( $i <  $n) {
            $t .= $text[ rand(0,$k) ];
            $i++;
        }
        return $t;
    }
    function TextW($n1,$n2) {
        $text = "Lorem,Ipsum,is,simply,dummy,text,of,the,printing,and,typesetting,industry.,Lorem,Ipsum,has,been,the,industry's,standard,dummy,text,ever,since,the,1500s,,when,an,unknown,printer,took,a,galley,of,type,and,scrambl";
        $text = split(",",$text);
        $n = rand($n1,$n2);
        $t="";
        $i=0;
        while($i <  $n) {
            $t .= $text[ $i%count($text)    ]  . ' ';
            $i++;
        }
        return $t;
    }

	$page = (int)$_POST['page'];
	$sort = (int)$_POST['sortType'];
	$size = 10;
	$itemTotal = 5000;
	$pagination = array('itemTotal'=>$itemTotal, 'itemPage'=>$size, 'pageCur'=>$page);
	$conditions = $_POST;
	$i = ($page-1)*$size;
	$k = $i+$size;
	$n = $k;
	for($i;$i<$k;$i++){
		$list[] = array(
			'id'=>(($sort==1)?$i+1:$n),
			'name'=>TextC(array('赵','钱','孙','李','周','吴','王','刘','孔','林'),2,4),
			'gender'=>TextC(array('男','女'),1,1),
			'age'=>TextC(array(1,2,3,4,5,6,7,8,9),2,2),
			'tel'=>TextC(array(1,2,3,4,5,6,7,8,9,0),6,8),
			'marry'=>TextC(array('已婚','未婚'),1,1),
			'addr'=>TextC(array('壹','貳','參','肆','伍','陸','柒','捌','玖','拾'),5,20),
			);
		$n--;
	}
	$result = array('state'=>1,'data'=>array('list'=>$list,'pagination'=>$pagination,'conditions'=>$conditions,'caption'=>'作者列表'),'errors'=>'');
	echo json_encode($result);
?>